﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="InitHelper.cs" company="dimamartovoi">
//   Apache License
//   Version 2.0, January 2004
//   http://www.apache.org/licenses
// </copyright>
// <summary>
//   The init helper.
// </summary>
// --------------------------------------------------------------------------------------------------------------------



using System.Collections.Generic;

namespace ActorModel.Infrastructure.Configuration.Ivashenko.Helpers
{
    /// <summary>
    /// The init helper.
    /// </summary>
    public static class InitHelper
    {
        #region Public Methods and Operators

        /// <summary>
        /// The init default state.
        /// </summary>
        /// <param name="parameters">
        /// The parameters.
        /// </param>
        /// <param name="defaultState">
        /// The default state.
        /// </param>
        public static void InitDefaultState(this EngineStartParameters<string> parameters, string defaultState)
        {
            parameters.NodesInitialStates = new Dictionary<int, string>(parameters.NumberOfNodes);
            for (int i = 0; i < parameters.NumberOfNodes; i++)
            {
                parameters.NodesInitialStates.Add(i, defaultState);
            }

            parameters.ConnectorsInfo =
                new Dictionary<int, ConnectorInfo<string>>(parameters.NumberOfNodeConnectors * parameters.NumberOfNodes);
            for (int i = 0; i < parameters.NumberOfNodes; i++)
            {
                for (int j = 0; j < parameters.NumberOfNodeConnectors; j++)
                {
                    int connectorId = (i * parameters.NumberOfNodeConnectors) + j;
                    parameters.ConnectorsInfo.Add(connectorId, new ConnectorInfo<string>(defaultState, connectorId));
                }
            }
        }

        #endregion
    }
}